        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>Fixture class / box2d Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d" data-type="Fixture">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d.html">box2d</a> &rsaquo; <a href="../box2d/Fixture.html">Fixture</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>Fixture</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<pre class="source">
class Fixture {
 final AxisAlignedBox box;

 num density;

 Fixture next;

 Body body;

 Shape shape;

 num friction;

 num restitution;

 DynamicTreeNode proxy;

 final Filter filter;

 bool isSensor;

 Object userData;

 final AxisAlignedBox _poolOne;
 final AxisAlignedBox _poolTwo;

 /** Constructs a new Fixture with default values. */
 Fixture()
     : box = new AxisAlignedBox(),
       body = null,
       next = null,
       proxy = null,
       shape = null,
       filter = new Filter(),
       _poolOne = new AxisAlignedBox(),
       _poolTwo = new AxisAlignedBox();

 /** Sets this fixture according to the given body and definition. */
 void create(Body b, FixtureDef def) {
   userData = def.userData;
   friction = def.friction;
   restitution = def.restitution;

   body = b;
   next = null;

   filter.setFrom(def.filter);

   isSensor = def.isSensor;

   shape = def.shape.clone();

   density = def.density;
 }

 /**
  * Destroys this fixture. Before being called, this shape's proxy must be
  * destroyed. After being called, this fixture's shape is null.
  */
 void destroy() {
   // The proxy must be destroyed before calling this.
   assert(proxy == null);

   // Free the child shape.
   shape = null;
 }

 /** These support body activation/deactivation. */
 void createProxy(BroadPhase broadPhase, Transform xf){
   assert(proxy == null);

   // Create proxy in the broad-phase.
   shape.computeAxisAlignedBox(box, xf);
   proxy = broadPhase.createProxy(box, this);
 }

 /** Destroys this Fixture's proxy. */
 void destroyProxy(BroadPhase broadPhase) {
   // If proxy is already destroyed, do nothing.
   if (proxy == null) {
     return;
   }

   // Destroy the proxy.
   broadPhase.destroyProxy(proxy);
   proxy = null;
 }

 //TODO(gregbglw): Write comment once know what does.
 void synchronize(BroadPhase broadPhase, Transform transformOne,
     Transform transformTwo) {
   if (proxy == null) {
     return;
   }

   // Compute an Axis Aligned Box that covers the swept shape.
   shape.computeAxisAlignedBox(_poolOne, transformOne);
   shape.computeAxisAlignedBox(_poolTwo, transformTwo);
   box.lowerBound.x = _poolOne.lowerBound.x &lt; _poolTwo.lowerBound.x ? 
       _poolOne.lowerBound.x : _poolTwo.lowerBound.x;
   box.lowerBound.y = _poolOne.lowerBound.y &lt; _poolTwo.lowerBound.y ?
       _poolOne.lowerBound.y : _poolTwo.lowerBound.y;
   box.upperBound.x = _poolOne.upperBound.x &gt; _poolTwo.upperBound.x ?
       _poolOne.upperBound.x : _poolTwo.upperBound.x;
   box.upperBound.y = _poolOne.upperBound.y &gt; _poolTwo.upperBound.y ?
       _poolOne.upperBound.y : _poolTwo.upperBound.y;

   vec2 disp = _poolOne.lowerBound;
   disp.copyFrom(transformTwo.position).sub(transformOne.position);

   broadPhase.moveProxy(proxy, box, disp);
 }

 /**
  * Get the mass data for this fixture. The mass data is based on the density
  * and the shape. The rotational inertia is about the shape's origin.
  */
 void getMassData(MassData massData) {
   shape.computeMass(massData, density);
 }

 /** Get the type of the child shape. */
 int get type =&gt; shape.type;
}
</pre>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="Fixture">
<button class="show-code">Code</button>
new <strong>Fixture</strong>() <a class="anchor-link" href="#Fixture"
              title="Permalink to Fixture.Fixture">#</a></h4>
<div class="doc">
<p>Constructs a new Fixture with default values. </p>
<pre class="source">
Fixture()
   : box = new AxisAlignedBox(),
     body = null,
     next = null,
     proxy = null,
     shape = null,
     filter = new Filter(),
     _poolOne = new AxisAlignedBox(),
     _poolTwo = new AxisAlignedBox();
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="body">
<button class="show-code">Code</button>
<a href="../box2d/Body.html">Body</a>         <strong>body</strong> <a class="anchor-link"
            href="#body"
            title="Permalink to Fixture.body">#</a>
        </h4>
        <div class="doc">
<pre class="source">
body
</pre>
</div>
</div>
<div class="field"><h4 id="box">
<button class="show-code">Code</button>
final <a href="../box2d/AxisAlignedBox.html">AxisAlignedBox</a>         <strong>box</strong> <a class="anchor-link"
            href="#box"
            title="Permalink to Fixture.box">#</a>
        </h4>
        <div class="doc">
<pre class="source">
box
</pre>
</div>
</div>
<div class="field"><h4 id="density">
<button class="show-code">Code</button>
num         <strong>density</strong> <a class="anchor-link"
            href="#density"
            title="Permalink to Fixture.density">#</a>
        </h4>
        <div class="doc">
<pre class="source">
density
</pre>
</div>
</div>
<div class="field"><h4 id="filter">
<button class="show-code">Code</button>
final <a href="../box2d/Filter.html">Filter</a>         <strong>filter</strong> <a class="anchor-link"
            href="#filter"
            title="Permalink to Fixture.filter">#</a>
        </h4>
        <div class="doc">
<pre class="source">
filter
</pre>
</div>
</div>
<div class="field"><h4 id="friction">
<button class="show-code">Code</button>
num         <strong>friction</strong> <a class="anchor-link"
            href="#friction"
            title="Permalink to Fixture.friction">#</a>
        </h4>
        <div class="doc">
<pre class="source">
friction
</pre>
</div>
</div>
<div class="field"><h4 id="isSensor">
<button class="show-code">Code</button>
bool         <strong>isSensor</strong> <a class="anchor-link"
            href="#isSensor"
            title="Permalink to Fixture.isSensor">#</a>
        </h4>
        <div class="doc">
<pre class="source">
isSensor
</pre>
</div>
</div>
<div class="field"><h4 id="next">
<button class="show-code">Code</button>
<a href="../box2d/Fixture.html">Fixture</a>         <strong>next</strong> <a class="anchor-link"
            href="#next"
            title="Permalink to Fixture.next">#</a>
        </h4>
        <div class="doc">
<pre class="source">
next
</pre>
</div>
</div>
<div class="field"><h4 id="proxy">
<button class="show-code">Code</button>
<a href="../box2d/DynamicTreeNode.html">DynamicTreeNode</a>         <strong>proxy</strong> <a class="anchor-link"
            href="#proxy"
            title="Permalink to Fixture.proxy">#</a>
        </h4>
        <div class="doc">
<pre class="source">
proxy
</pre>
</div>
</div>
<div class="field"><h4 id="restitution">
<button class="show-code">Code</button>
num         <strong>restitution</strong> <a class="anchor-link"
            href="#restitution"
            title="Permalink to Fixture.restitution">#</a>
        </h4>
        <div class="doc">
<pre class="source">
restitution
</pre>
</div>
</div>
<div class="field"><h4 id="shape">
<button class="show-code">Code</button>
<a href="../box2d/Shape.html">Shape</a>         <strong>shape</strong> <a class="anchor-link"
            href="#shape"
            title="Permalink to Fixture.shape">#</a>
        </h4>
        <div class="doc">
<pre class="source">
shape
</pre>
</div>
</div>
<div class="field"><h4 id="type">
<button class="show-code">Code</button>
final int         <strong>type</strong> <a class="anchor-link"
            href="#type"
            title="Permalink to Fixture.type">#</a>
        </h4>
        <div class="doc">
<p>Get the type of the child shape. </p>
<pre class="source">
int get type =&gt; shape.type;
</pre>
</div>
</div>
<div class="field"><h4 id="userData">
<button class="show-code">Code</button>
Object         <strong>userData</strong> <a class="anchor-link"
            href="#userData"
            title="Permalink to Fixture.userData">#</a>
        </h4>
        <div class="doc">
<pre class="source">
userData
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="create">
<button class="show-code">Code</button>
void <strong>create</strong>(<a href="../box2d/Body.html">Body</a> b, <a href="../box2d/FixtureDef.html">FixtureDef</a> def) <a class="anchor-link" href="#create"
              title="Permalink to Fixture.create">#</a></h4>
<div class="doc">
<p>Sets this fixture according to the given body and definition. </p>
<pre class="source">
void create(Body b, FixtureDef def) {
 userData = def.userData;
 friction = def.friction;
 restitution = def.restitution;

 body = b;
 next = null;

 filter.setFrom(def.filter);

 isSensor = def.isSensor;

 shape = def.shape.clone();

 density = def.density;
}
</pre>
</div>
</div>
<div class="method"><h4 id="createProxy">
<button class="show-code">Code</button>
void <strong>createProxy</strong>(<a href="../box2d/BroadPhase.html">BroadPhase</a> broadPhase, <a href="../box2d/Transform.html">Transform</a> xf) <a class="anchor-link" href="#createProxy"
              title="Permalink to Fixture.createProxy">#</a></h4>
<div class="doc">
<p>These support body activation/deactivation. </p>
<pre class="source">
void createProxy(BroadPhase broadPhase, Transform xf){
 assert(proxy == null);

 // Create proxy in the broad-phase.
 shape.computeAxisAlignedBox(box, xf);
 proxy = broadPhase.createProxy(box, this);
}
</pre>
</div>
</div>
<div class="method"><h4 id="destroy">
<button class="show-code">Code</button>
void <strong>destroy</strong>() <a class="anchor-link" href="#destroy"
              title="Permalink to Fixture.destroy">#</a></h4>
<div class="doc">
<p>Destroys this fixture. Before being called, this shape's proxy must be
destroyed. After being called, this fixture's shape is null.</p>
<pre class="source">
void destroy() {
 // The proxy must be destroyed before calling this.
 assert(proxy == null);

 // Free the child shape.
 shape = null;
}
</pre>
</div>
</div>
<div class="method"><h4 id="destroyProxy">
<button class="show-code">Code</button>
void <strong>destroyProxy</strong>(<a href="../box2d/BroadPhase.html">BroadPhase</a> broadPhase) <a class="anchor-link" href="#destroyProxy"
              title="Permalink to Fixture.destroyProxy">#</a></h4>
<div class="doc">
<p>Destroys this Fixture's proxy. </p>
<pre class="source">
void destroyProxy(BroadPhase broadPhase) {
 // If proxy is already destroyed, do nothing.
 if (proxy == null) {
   return;
 }

 // Destroy the proxy.
 broadPhase.destroyProxy(proxy);
 proxy = null;
}
</pre>
</div>
</div>
<div class="method"><h4 id="getMassData">
<button class="show-code">Code</button>
void <strong>getMassData</strong>(<a href="../box2d/MassData.html">MassData</a> massData) <a class="anchor-link" href="#getMassData"
              title="Permalink to Fixture.getMassData">#</a></h4>
<div class="doc">
<p>Get the mass data for this fixture. The mass data is based on the density
and the shape. The rotational inertia is about the shape's origin.</p>
<pre class="source">
void getMassData(MassData massData) {
 shape.computeMass(massData, density);
}
</pre>
</div>
</div>
<div class="method"><h4 id="synchronize">
<button class="show-code">Code</button>
void <strong>synchronize</strong>(<a href="../box2d/BroadPhase.html">BroadPhase</a> broadPhase, <a href="../box2d/Transform.html">Transform</a> transformOne, <a href="../box2d/Transform.html">Transform</a> transformTwo) <a class="anchor-link" href="#synchronize"
              title="Permalink to Fixture.synchronize">#</a></h4>
<div class="doc">
<pre class="source">
void synchronize(BroadPhase broadPhase, Transform transformOne,
   Transform transformTwo) {
 if (proxy == null) {
   return;
 }

 // Compute an Axis Aligned Box that covers the swept shape.
 shape.computeAxisAlignedBox(_poolOne, transformOne);
 shape.computeAxisAlignedBox(_poolTwo, transformTwo);
 box.lowerBound.x = _poolOne.lowerBound.x &lt; _poolTwo.lowerBound.x ? 
     _poolOne.lowerBound.x : _poolTwo.lowerBound.x;
 box.lowerBound.y = _poolOne.lowerBound.y &lt; _poolTwo.lowerBound.y ?
     _poolOne.lowerBound.y : _poolTwo.lowerBound.y;
 box.upperBound.x = _poolOne.upperBound.x &gt; _poolTwo.upperBound.x ?
     _poolOne.upperBound.x : _poolTwo.upperBound.x;
 box.upperBound.y = _poolOne.upperBound.y &gt; _poolTwo.upperBound.y ?
     _poolOne.upperBound.y : _poolTwo.upperBound.y;

 vec2 disp = _poolOne.lowerBound;
 disp.copyFrom(transformTwo.position).sub(transformOne.position);

 broadPhase.moveProxy(proxy, box, disp);
}
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
